import Vue from 'vue'
import Vuex from 'vuex'
import { getItem, setItem } from '../utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    userToken: getItem('userToken'),
    sotrageChannels: getItem('channels')
  },
  mutations: {
    addToken: function (state, userToken) {
      state.userToken = userToken
      // 存储到本地
      setItem('userToken', userToken)
    },
    channelsChange: function (state, Channels) {
      state.sotrageChannels = Channels
      // 存储到本地
      setItem('channels', Channels)
    }
  },
  actions: {
  },
  modules: {
  }
})
